/*
 * Copyright Groupe Adeo 2009
 * 
 * Licensed under New BSD License : http://www.opensource.org/licenses/bsd-license.php
 */
package com.adeoservices.gwt.dispatch.spring.server.security;

import org.springframework.security.core.Authentication;
import org.springframework.security.core.GrantedAuthority;

/**
 * 
 * @author Olivier HEDIN / Adeo Services
 *
 */
public class PermissionUtils {

	public static boolean hasRole(Authentication authentication, String roleName)
	{
		for (GrantedAuthority grantedAuthority : authentication.getAuthorities()) {
			if (roleName.equalsIgnoreCase(grantedAuthority.getAuthority()))
			{
				return true;
			}
		}
		
		return false;
	}
}
